package io.gitee.cloudladder.obsidian.swagger2.example.controller;

import io.gitee.cloudladder.obsidian.swagger2.annotation.ApiOperationSort;
import io.gitee.cloudladder.obsidian.swagger2.example.entity.BaseDataTypeParamObject;
import io.gitee.cloudladder.obsidian.swagger2.example.entity.ExtendDataTypeParamObject;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Slf4j
@Api(value = "Test Body Parameter Controller")
@RestController
public class TestBodyParameterController {

    @ApiOperationSort(1)
    @PostMapping("/test/body/string")
    public void testBodyString(@RequestBody String param) {
        log.info("testBodyString: param = {}", param);
    }

    @ApiOperationSort(2)
    @PostMapping("/test/body/byte")
    public void testBodyByte(@RequestBody Byte param) {
        log.info("testBodyByte: param = {}", param);
    }

    @ApiOperationSort(3)
    @PostMapping("/test/body/short")
    public void testBodyShort(@RequestBody Short param) {
        log.info("testBodyShort: param = {}", param);
    }

    @ApiOperationSort(4)
    @PostMapping("/test/body/integer")
    public void testBodyInteger(@RequestBody Integer param) {
        log.info("testBodyInteger: param = {}", param);
    }

    @ApiOperationSort(5)
    @PostMapping("/test/body/long")
    public void testBodyLong(@RequestBody Long param) {
        log.info("testBodyLong: param = {}", param);
    }

    @ApiOperationSort(6)
    @PostMapping("/test/body/float")
    public void testBodyFloat(@RequestBody Float param) {
        log.info("testBodyFloat: param = {}", param);
    }

    @ApiOperationSort(7)
    @PostMapping("/test/body/double")
    public void testBodyDouble(@RequestBody Double param) {
        log.info("testBodyDouble: param = {}", param);
    }

    @ApiOperationSort(8)
    @PostMapping("/test/body/date")
    public void testBodyDate(@RequestBody Date param) {
        log.info("testBodyDate: param = {}", param);
    }

    @ApiOperationSort(9)
    @PostMapping("/test/body/localDate")
    public void testBodyLocalDate(@RequestBody LocalDate param) {
        log.info("testBodyLocalDate: param = {}", param);
    }

    @ApiOperationSort(10)
    @PostMapping("/test/body/array/string")
    public void testBodyArrayString(@RequestBody String[] param) {
        for(int i = 0; i < param.length; i ++) {
            log.info("testBodyArrayString: param[{}] = {}", i, param[i]);
        }
    }

    @ApiOperationSort(11)
    @PostMapping("/test/body/array/integer")
    public void testBodyArrayInteger(@RequestBody Integer[] param) {
        for(int i = 0; i < param.length; i ++) {
            log.info("testBodyArrayInteger: param[{}] = {}", i, param[i]);
        }
    }

    @ApiOperationSort(12)
    @PostMapping("/test/body/list/string")
    public void testBodyListString(@RequestBody List<String> param) {
        for(int i = 0; i < param.size(); i ++) {
            log.info("testBodyListString: param[{}] = {}", i, param.get(i));
        }
    }

    @ApiOperationSort(13)
    @PostMapping("/test/body/list/integer")
    public void testBodyListInteger(@RequestBody List<Integer> param) {
        for(int i = 0; i < param.size(); i ++) {
            log.info("testBodyListInteger: param[{}] = {}", i, param.get(i));
        }
    }

    @ApiOperationSort(14)
    @PostMapping("/test/body/map")
    public void testBodyMap(@RequestBody Map<String, String> param) {
        log.info("testBodyMap: param = {}", param);
    }

    @ApiOperationSort(15)
    @PostMapping("/test/body/object/base")
    public void testBodyObjectBase(@RequestBody BaseDataTypeParamObject params) {
        log.info("testBodyObjectBase: params = {}", params.toString());
    }

    @ApiOperationSort(16)
    @PostMapping("/test/body/object/extend")
    public void testBodyObjectExtend(@RequestBody ExtendDataTypeParamObject param) {
        log.info("testBodyObjectExtend: params = {}", param.toString());
    }

}

